﻿using System.Linq;
using System.Web.Mvc;
using Citi.GocAttributes.Domain;
using Citi.GocAttributes.WebUI.Models;
using Webdiyer.WebControls.Mvc;

namespace Citi.GocAttributes.WebUI.Controllers
{
    public class ImportHistoryController : ControllerBase<ImportHistoryModel, ImportHistory>
    {
        public ActionResult Index()
        {
            IndexBase();

            return View(Models.OrderByDescending(x => x.UploadDate));
        }

        public ActionResult Details(int id, int page = 1)
        {
            DetailsBase(id);
            var pagedList = new PagedList<ImportErrorModel>(Model.ImportErrors, page, 10);

            if (Request.IsAjaxRequest())
                return PartialView("~/Views/ImportError/List.cshtml", pagedList);

            Model.ImportErrors = pagedList;
            return View(Model);
        }
    }
}
